package com.brs.model;

import java.util.Date;

public class Card {
	private int id;
	private String holder;
	private Date issuedTime;
	private Date expiredTime;
	private float balance;

	public Card(int id, String holder, Date issued, Date expired, float balance) {
		this.id = id;
		this.holder = holder;
		this.issuedTime = issued;
		this.expiredTime = expired;
		this.balance = balance;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getHolder() {
		return holder;
	}

	public void setHolder(String holder) {
		this.holder = holder;
	}

	public Date getIssuedTime() {
		return issuedTime;
	}

	public void setIssuedTime(Date issuedTime) {
		this.issuedTime = issuedTime;
	}

	public Date getExpiredTime() {
		return expiredTime;
	}

	public void setExpiredTime(Date expiredTime) {
		this.expiredTime = expiredTime;
	}

	public float deduct(float amount) {
		if (balance >= amount) {
			balance -= amount;
			return balance;
		} else {
			// TODO: Not enough balance!
			return -1;
		}
	}

	public float recharge(float amount) {
		balance += amount
		return balance;
	}

	public float queryBalance() {
		return balance;
	}

	@Override
	public String toString() {
		return "Card [id=" + id + ", holder=" + holder + ", issuedTime=" + issuedTime + ", expiredTime=" + expiredTime
				+ ", balance=" + balance + "]";
	}

}
